import log from '@dfeidao/atom-nodejs/logger/log';
import { IncomingHttpHeaders } from 'http';
import { systemid, productid } from '../../atom/config';
import query from '@dfeidao/atom-nodejs/db/query';

interface Message {
	sub_process_no: string,
}

interface IWebResult {
	data: unknown;
	cookie?: {
		[name: string]: string;
	} | null;
	content_type?: string;
	headers?: {
		[key: string]: string;
	};
	attachment?: string;
	redirect?: string;
	status_code?: number;
}

export default async function atom(message: Message, action_id: string, session_id: string, headers: IncomingHttpHeaders): Promise<IWebResult> {
	log('Service begin path:e:\Feidao\kh\src\processing-set\zj-000003\s002,action_id:' + action_id);

	const { prepare, exec } = query(action_id, session_id, systemid);
	prepare('hidden_ck_deal_set', ['sub_process_des', 'sub_process_no'], { productid, sub_process_no: message.sub_process_no }, 10, 1, [], []);
	const [data] = await exec();

	log('Service end path:e:\Feidao\kh\src\processing-set\zj-000003\s002,action_id:' + action_id);
	return {
		data: data
	};
}
